﻿using System;
using HarrisDesigns.Controls.dasBlogControls.Google.Reader;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace dasBlogControls.Test.Google.Reader
{
    [TestClass]
    public class WhenAccessingFeedItemInformation
    {
        private FeedItem _context;
        public FeedItem Context
        {
            get
            {
                if (_context == null)
                {
                    _context = new FeedItem();
                    _context.PublishedSeconds = 1255049000;
                    _context.UpdatedSeconds = 1255049730;
                    _context.Content = @"I sent @someone to http://www.microsoft.com @ 5:00";
                }
                return _context;
            }
        }

        [TestMethod]
        public void ItShouldHaveTheExpectedPublishedTime()
        {
            var timestamp = new DateTime(2009, 10, 9, 0, 43, 20, DateTimeKind.Local);
            Assert.AreEqual(timestamp.ToLocalTime(), Context.Published);
        }
        [TestMethod]
        public void ItShouldHaveTheExpectedUpdatedTime()
        {
            var timestamp = new DateTime(2009, 10, 9, 0, 55, 30, DateTimeKind.Local);
            Assert.AreEqual(timestamp.ToLocalTime(), Context.Updated);
        }
        [TestMethod]
        public void ItShouldConvertUrlsToLinks()
        {
            Assert.IsTrue(Context.GetTextAsHtml().Contains(@"to <a href=""http://www.microsoft.com"">http://www.microsoft.com</a> "));
        }
    }
}